package com.lagou.controller;

import com.alibaba.dubbo.config.annotation.Reference;
import com.lagou.entity.Course;
import com.lagou.service.CourseService;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@RequestMapping("/course")
public class CourseController {

    @Reference
    private CourseService courseService;

    @GetMapping("/getAllCourse")
    public List<Course> getAllCourse(){

        return courseService.getAllCourse();
    }

    @GetMapping("/getCourseByUserId/{userId}")
    public List<Course> getCourseByUserId(@PathVariable("userId") Integer userId) {

        return courseService.getCourseByUserId(userId);
    }

    @GetMapping("/getCourseById/{courseId}")
    public Course getCourseById(@PathVariable("courseId") Integer courseId) {

        return courseService.getCourseById(courseId);
    }
}
